package com.nbgs.demo.dao;

import com.nbgs.demo.controller.form.Form;
import com.nbgs.demo.model.ActiverUser;
import com.nbgs.demo.model.Worker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AuthMapper {
    @Select("select * from t_worker")
    List<Worker> findAll();

    @Select("select * from t_worker where worker_name=#{workerNum}")
    List<Worker> workers(String workerName);

    @Select("select t3.role_name,t4.permission_name " +
            "from t_worker t1 join t_worker_role t2 join t_role t3 " +
            "on t1.worker_id=t2.worker_id and t3.role_id=t2.role_id " +
            "join t_permission t4 join t_role_permission t5 " +
            "on t4.permission_id=t5.permission_id and t5.role_id=t3.role_id where worker_name=#{workerName};")
    List<ActiverUser> activerUsers(String workerName);

    @Insert("insert into t_worker(worker_name,worker_password) values (#{workerName},#{workerPassword})")
    void addWorker(Form form);
}
